#include "actorpropertypage.h"
#include "gameObjects/actor.h"

ActorPropertyPage::ActorPropertyPage(QWidget *parent)
	: QWidget(parent)
{
	ui.setupUi(this);
}

void ActorPropertyPage::setActor( QPointer<AbstractGameObject> actor )
{
	if(m_actor)
	{
		disconnect(ui.lineEditName, &QLineEdit::textChanged, 
			m_actor, &AbstractGameObject::setName);
	}

	m_actor = actor;

	if(m_actor)
	{
		connect(ui.lineEditName, &QLineEdit::textChanged, 
			m_actor, &AbstractGameObject::setName);
		ui.lineEditName->setText(m_actor->name());
	}

	ui.lineEditName->setFocus();
	ui.lineEditName->selectAll();
}
